# TODO 字典的修改

# 通过key修改字典的内容

dict1 = {'name':'张三','age':25,'job':'teacher'}

dict1['name'] = '李四'
print(dict1)

# 如果key不存在就是新增
dict1['hobby'] = '打篮球'
print(dict1)

# 设置默认的key,value,默认属性不存在的时候,新增
dict1.setdefault('性别','男')
print(dict1)

# 已经设置过了默认属性
dict1.setdefault('性别','女')
print(dict1)

# 合并2个字典
dict2 = {'hobby':'打篮球','height':185}
dict1.update(dict2)
print(dict1)

dict3 = {'hobby':'打篮球','height':185,'job':'singer'}
dict1.update(dict3)
print(dict1)
